#!/bin/bash
# parameter 1: process name

process=$1

WAIT_COUNT=0
while [ $WAIT_COUNT -lt 120 ]; do
	ps aux | grep $process | grep -v 'grep' | grep -v 'wait_process_exit' >/dev/null 2>&1
	ret=$?
	if [ "$ret" != "0" ]; then
		echo "process $process already exit"
		exit 0
	fi
	sleep 1
	echo "wait process $process exit..."
	((WAIT_COUNT++))
done

echo "process $process didn't exit after 120 seconds, current processlist: $(ps aux | grep $process | grep -v 'grep' | grep -v 'wait_process_exit')"
exit 1
